package com.study.controller;

import com.study.entity.User;
import com.study.service.UserService;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.mvc.Controller;

/**
 * @Author chenyeqing
 * @Date 2021/10/31 15:12
 */
public class UserController implements Controller {

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        User user = new User();
        user.setName(httpServletRequest.getParameter("name"));
        user.setName(httpServletRequest.getParameter("password"));

        userService.register(user);

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("ok");
        return modelAndView;
    }
}
